import { ClassicModel } from '../../models/classic.js'
import { LikeModel } from '../../models/like.js'
let classicModel = new ClassicModel()
let likeModel = new LikeModel()

Page({
  /**
   * Page initial data
   */
  data: {
    classic: {},
    latest: true,
    first: false,
    cardList: [
      {
        auth: 1,
        distance: 0.4,
        image: "https://extraimage.net/images/2019/01/25/445a651866dd49c588df7c66b62bea6e.jpg",
        title: "印度暴徒",
        tag: "印度 | 宝莱坞 | 动作 | 2018 | 喜剧 | 剧情 | 历史 | 冒险",
        school: "北京**大学",
        stars: 3.9
      },
      {
        auth: 1,
        distance: 0.4,
        image: "https://extraimage.net/images/2019/06/12/56285ed29d3217f5b79f1905bf93f0d1.jpg",
        title: "五尺天涯",
        tag: "爱情 | 青春 | 生命 | 美国 | 2019 | 剧情 | 疾病 | 恋爱",
        school: "北京**大学",
        stars: 9.2
      },
      {
        auth: 1,
        distance: 0.6,
        image: "https://extraimage.net/images/2019/07/20/e8f7fb12e943b9aace60f7a46494402a.jpg",
        title: "那些年，我们一起追的女孩",
        tag: "日本 | 斋藤飞鸟 | 青春 | 爱情 | 日本电影 | 2018 | 那些年翻拍 | 翻拍版本",
        school: "北京**大学",
        stars: 6.7
      },
      {
        auth: 1,
        distance: 0.6,
        image: "https://extraimage.net/images/2019/07/29/0e698985a424dab293826d167a36baa0.jpg",
        title: "城市猎人",
        tag: "喜剧 | 法国 | 漫画改编 | 搞笑 | 动作 | 2019 | 法国电影 | 剧情",
        school: "北京**大学",
        stars: 7.1
      }
    ]
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad: function (options) {
    classicModel.getLatest((res)=>{
      console.log(res)
      this.setData({
        classic: res.data
      })
    })
  },

  onLike:function(event){
    // console.log(event)
    let behavior = event.detail.behavior
    likeModel.like(behavior, this.data.classic.id, this.data.classic.type)
  },
  onPrevious:function(event){
    console.log(event)
    // let behavior = event.detail.behavior
    // likeModel.like(behavior, this.data.classic.id, this.data.classic.type)
  },
  onNext:function(event){
    console.log(event)
    // let behavior = event.detail.behavior
    // likeModel.like(behavior, this.data.classic.id, this.data.classic.type)
  },
  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady: function () {

  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow: function () {

  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide: function () {

  },

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload: function () {

  },

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh: function () {

  },

  /**
   * Called when page reach bottom
   */
  onReachBottom: function () {

  },

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage: function () {

  }
})